﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace TEL.TelPhoneF
{
    public partial class frmBalloonTip : Form
    {
        private int tic = 0;
        private bool mIsMouseEnter = false;
        private void setIsMouseEnter(bool value)
        {
            mIsMouseEnter = value;
            if (mIsMouseEnter)
            {
                tic = 0;
                Opacity = 100;
            }
        }

        public event EventHandler Ansver;
        public event EventHandler Cansel;

        public frmBalloonTip()
        {
            TopMost = true;
            InitializeComponent();
            SetStyle(ControlStyles.Selectable, false);
            //button1.(ControlStyles.Selectable, false);
            //button1.SetStyle(ControlStyles.Selectable, false);
            button2.Image = Properties.Resources.user_red;
            button1.Image = Properties.Resources.user_green;
        }

        private void frmBalloonTip_Load(object sender, EventArgs e)
        {
            int x = Screen.PrimaryScreen.WorkingArea.Width - Width;
            int y = Screen.PrimaryScreen.WorkingArea.Height - Height;
            Location = new Point(x, y) - new Size(2, 9);
            timer1.Enabled = true;
            timer1.Start();
            WindowState = FormWindowState.Normal;

        }

        private void timer1_Tick(object sender, EventArgs e)
        {
            tic++;
            if (tic > 50 && Opacity > 0)
                Opacity = Opacity - 0.01;
            if (Opacity == 0) Close();
        }

        private void frmBalloonTip_MouseEnter(object sender, EventArgs e)
        {
            setIsMouseEnter(true);
        }

        private void frmBalloonTip_MouseLeave(object sender, EventArgs e)
        {
            setIsMouseEnter(false);
        }

        public string DisplayName
        {
            set { lDisplayName.Text = value; }
        }

        public string Number
        {
            set { lNumber.Text = value; }
        }

        private void button1_Click(object sender, EventArgs e)
        {
            if (Ansver != null) Ansver(this, EventArgs.Empty);
            Close();
        }

        private void button2_Click(object sender, EventArgs e)
        {

            if (Cansel != null) Cansel(this, EventArgs.Empty);
            Close();
        }

        private void buttonOption1_Click(object sender, EventArgs e)
        {
            Close();
        }
    }
}
